package com.openx.cloud.server.autoconfigure.feign;

import org.springframework.http.HttpHeaders;

import java.util.*;

/**
 * @author yadu
 */
public  class FeignUtil {
        private FeignUtil() {
            throw new IllegalStateException("Can't instantiate a utility class");
        }

        static HttpHeaders getHeaders(Map<String, Collection<String>> headers) {
            HttpHeaders httpHeaders = new HttpHeaders();
            Iterator var2 = headers.entrySet().iterator();

            while(var2.hasNext()) {
                Map.Entry<String, Collection<String>> entry = (Map.Entry)var2.next();
                httpHeaders.put((String)entry.getKey(), new ArrayList((Collection)entry.getValue()));
            }

            return httpHeaders;
        }

        static Map<String, Collection<String>> getHeaders(HttpHeaders httpHeaders) {
            LinkedHashMap<String, Collection<String>> headers = new LinkedHashMap();
            Iterator var2 = httpHeaders.entrySet().iterator();

            while(var2.hasNext()) {
                Map.Entry<String, List<String>> entry = (Map.Entry)var2.next();
                headers.put(entry.getKey(), entry.getValue());
            }

            return headers;
        }

        static Collection<String> addTemplateParameter(Collection<String> possiblyNull, String paramName) {
            Collection<String> params = (Collection)Optional.ofNullable(possiblyNull).map(ArrayList::new).orElse(new ArrayList());
            params.add(String.format("{%s}", paramName));
            return params;
        }
    }
